package com.online.taxi.order.implementation.redis;

import com.online.taxi.order.implementation.LockKey;

import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Author:jiangqikun
 * @Date:2022/8/21 14:27
 **/

public class RedisLockUse {

    @Autowired
    private RedisLock redisLock;

    public void use(String orderId , String driverId){
        // 生成 key
        LockKey key = LockKey.builder()
                .driverId(driverId)
                .orderId(orderId)
                .build();
        redisLock.setLockKey(key);

        try {
            redisLock.lock();
            // 执行业务代码


        } finally {
            redisLock.unlock();
            }
        }

}
